'''
Created on Jul 24, 2012

@author: peng
'''


def _recount():
    f = open('/home/peng/special_event.out')
    count_dic = {}
    r = {}
    for line in f.readlines():
        values = line.split('\t')
        if values[3] == '240bffab92804697ab5dd70db5a34b03' \
            and values[14] == 'official':
            key = values[1] + '+' + values[3] + '+' + values[11] + '+' + \
                values[14] + '+' + values[19]
            if key in count_dic:
                count_dic[key] += 1
            else:
                count_dic[key] = 1

    for key in count_dic.keys():
        k = '+'.join(key.split('+')[1:])
        if k in r:
            r[k] += 1
        else:
            r[k] = 1

    for key in sorted(r.keys()):
        print '[%s][%s]' % (key, r[key])


def _get_updated_version():
    f = open('/home/peng/special_event.out')

    version_dict = {}

    for line in f.readlines():
        values = line.split('\t')
        if values[3] == '240bffab92804697ab5dd70db5a34b03' \
            and values[14] == 'official':
            key = values[1]
            if key in version_dict and values[11] \
                not in version_dict[key].split(','):
                version_dict[key] = version_dict[key] + ',' + values[11]
            else:
                version_dict[key] = values[11]

    for key in sorted(version_dict.keys()):
        if len(version_dict[key].split(',')) > 1:
            print '[%s][%s]' % (key, version_dict[key])

if __name__ == '__main__':
    _get_updated_version()
